﻿using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace WorkStation.UI.Controls
{
    public class MotionPoint : MotionShape
    {
        public PointF CenterPoint;
        public List<float> OriginPoint;
        public MotionPoint()
        {
            OriginPoint = new List<float>();
        }
        public MotionPoint(string description)
            : base(description)
        {

        }
        public override void Draw(Graphics g)
        {
            Pen p = new Pen(PaintColor, LineWidth);
            if (IsSelected)
            {
                p.Color = Color.LimeGreen;
                p.Width = 4;
                g.TranslateTransform(CenterPoint.X, CenterPoint.Y);
                g.RotateTransform(45f);
                g.DrawLine(p, new PointF(20, 0), new PointF(-20, 0));
                g.DrawLine(p, new PointF(0, -20), new PointF(0, 20));
                g.RotateTransform(-45f);
                g.TranslateTransform(-CenterPoint.X, -CenterPoint.Y);
                g.DrawString(Description, new Font("微软雅黑", 12, FontStyle.Regular), new SolidBrush(Color.Black), new PointF(this.CenterPoint.X, this.CenterPoint.Y - 10));
            }
            else
            {
                g.TranslateTransform(CenterPoint.X, CenterPoint.Y);
                g.RotateTransform(45f);
                g.DrawLine(p, new PointF(10, 0), new PointF(-10, 0));
                g.DrawLine(p, new PointF(0, -10), new PointF(0, 10));
                g.RotateTransform(-45f);
                g.TranslateTransform(-CenterPoint.X, -CenterPoint.Y);
                g.DrawString(Description, new Font("微软雅黑", 8, FontStyle.Regular), new SolidBrush(Color.DarkGreen), new PointF(this.CenterPoint.X, this.CenterPoint.Y - 10));
            }
        }
        public override PositionOnShape PointOnShape(PointF point)
        {
            //if(direction == AxisDir.Circle)
            //{
            //    if (distancePp(point, new PointF((float)OriginPoint[0], (float)OriginPoint[1])) < 1)
            //    {
            //        return PositionOnShape.In;
            //    }
            //}
            //else
            //{
                if (distancePp(point, new PointF((float)OriginPoint[0], (float)OriginPoint[1])) < 2)
                {
                    return PositionOnShape.In;
                }
            //}
            return base.PointOnShape(point);
        }
        public PositionOnShape PointOnShape2(double angle)
        {
            if (Math.Abs(angle - OriginPoint[2]) < 1)
                return PositionOnShape.In;
            else
                return PositionOnShape.Out;
        }
    }
}
